export const BasicMaterial_parse = /*wgsl*/ `
    fn parserMaterial(input:Input){
      material=baseMaterial;
      material.color=kc(input);
      material.emissive=ke(input);
      material.ambient=ka(input);
      //material.diffuse=kd(input);
      material.specular=ks(input);
      material.aoMapIntensity=baseMaterial.aoMapIntensity;
      material.refuseLight=baseMaterial.refuseLight;
      material.sdfFrom=baseMaterial.sdfFrom;
      material.sdfTo=baseMaterial.sdfTo;
    }
    fn cal_uv(input:Input)->vec2<f32>{
        var r:vec2<f32>=vec2(.0,.0);
        #if ~{def.uvWidthFactor && def.lineWidth && def.map_uvPixel}
          var uvWidthFactor:vec4<f32> = input.uvWidthFactor;
          r=vec2(uvWidthFactor[0]+uvWidthFactor[1]*pixelToWorld(lineWidth), uvWidthFactor[2]+uvWidthFactor[3]*pixelToWorld(lineWidth));
          r=vec2(r[0]/pixelToWorld(map_uvPixel), r[1]);
        #elif ~{def.texCood0}
            r=vec2(input.texCood0.x,input.texCood0.y);
        #endif
        #if ~{def.map_uvOffset}
        r = vec2(r[0] + map_uvOffset[0], r[1] + map_uvOffset[1]);
        #endif
        return r;
      }
      //获取基地色
      fn kc(input:Input)->vec4<f32>{
        var r:vec4<f32>=baseMaterial.color;
        #if ~{def.color}
          r=r*input.color;
        #endif
        #if ~{def.map && (def.texCood0 || def.uvWidthFactor)}
          var uv = cal_uv(input);
          #if ~{def.sdf}
          var dist:f32;
          dist = textureSample(map, map_sampler, uv ).r;
          var alpha:f32 = smoothstep(baseMaterial.sdfFrom, baseMaterial.sdfTo, dist);
          r.w=alpha;
          #else
          r*=textureSample(map, map_sampler, uv);
          #endif
        #endif
        return r;
      }
      //获取自发光系数
      fn ke(input:Input)->vec3<f32>{
        var r:vec3<f32>=baseMaterial.emissive;
        #if ~{def.emissiveMap && (def.texCood0 || def.uvWidthFactor)}
        var uv = cal_uv(input);
        r=r*textureSample(emissiveMap, emissiveMap_sampler, uv).xyz;
        #endif
        return r;
      }
      //获取环境光系数
      fn ka(input:Input)->vec3<f32>{
        var r:vec3<f32>=baseMaterial.ambient;
        #if ~{def.ambientMap && (def.texCood0 || def.uvWidthFactor)}
        var uv = cal_uv(input);
        r=r*textureSample(ambientMap, ambientMap_sampler, uv).xyz;
        #endif
        return r;
      }
      //获取漫反射系数
      fn kd(input:Input)->vec3<f32>{
        var r:vec3<f32>=baseMaterial.diffuse;
        #if ~{def.diffuseMap && (def.texCood0  || def.uvWidthFactor)}
        var uv = cal_uv(input);
        r=r*textureSample(diffuseMap, diffuseMap_sampler, uv).xyz;
        #endif
        return r;
      }
      //获取镜面反射系数
      fn ks(input:Input)->vec3<f32>{
        var r:vec3<f32>=baseMaterial.specular;
        #if ~{def.specularMap && (def.texCood0 || def.uvWidthFactor)}
        var uv = cal_uv(input);
        r=r*textureSample(specularMap, specularMap_sampler, uv).xyz;
        #endif
        return r;
      }
    `